package com.platform.gateway;

import javax.servlet.http.HttpServletRequest;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.platform.gateway.common.message.ResponseMsg;
import com.platform.gateway.common.utils.MsgUtils;

import io.swagger.annotations.ApiOperation;

// 网关注解
@EnableZuulProxy
// 注册中心注解
@EnableDiscoveryClient
@SpringBootApplication
@RestController
@EnableHystrixDashboard
public class PlatformGatewayApplication {

    public static void main(String[] args) {
        SpringApplication.run(PlatformGatewayApplication.class, args);
    }

    @SuppressWarnings("deprecation")
    @ApiOperation(value = "全局异常信息")
    @GetMapping(value = "/gobleError", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResponseMsg<String> gobleError(HttpServletRequest request) {
        return MsgUtils.buildFailureMsg("发生全局异常");
    }

}
